package Z5;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;

public class TestBean implements Serializable {
	private String name;
	private int nr;
	private PropertyChangeSupport chg = new PropertyChangeSupport(this);

	@Override
	public String toString() {
		return "TestBean [name=" + name + ", nr=" + nr + "]";
	}

	public TestBean() {
		this.name = "dmfjis";
		this.nr = 932829;
	}

	public String getName() {
		return name;
	}

	public void setName(String newName) {
		String oldName = name;
		name = newName;
		chg.firePropertyChange("name", oldName, newName);
	}

	public int getNr() {
		return nr;
	}

	public void setNr(int newNr) {
		int oldNr = nr;
		this.nr = newNr;
		chg.firePropertyChange("nr", oldNr, newNr);
	}

	public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
		chg.addPropertyChangeListener(l);
	}

	public synchronized void removePropertyChangeListener(
			PropertyChangeListener l) {
		chg.removePropertyChangeListener(l);
	}
}